import qs from 'qs'
import {
    AccountParams,
    AccountListGetResultModel,
    AccountCreateData,
    AccountUpdate, AccountListItem,
} from '../model/systemModel';
import {defHttp} from '/@/utils/http/axios';

enum Api {
    AccountList = '/account',
    AccountCreate = '/account',
    AccountUpdate = '/account',
    AccountDelete = '/account',
    AccountInfo='/account',
}

export const getAccountList = (params: AccountParams) =>
    defHttp.get<AccountListGetResultModel>({
            url: Api.AccountList, params, paramsSerializer: params => {
                return qs.stringify(params, {indices: false})
            }
        }
    );

export const postAccountCreate = (data: AccountCreateData) =>
    defHttp.post<AccountListItem>({url: Api.AccountCreate, data});


export const putAccountUpdate = (uid: string, data: AccountUpdate) =>
    defHttp.put<AccountListItem>({url: `${Api.AccountUpdate}/${uid}`, data});

export const deleteAccountUpdate = (uid: string) =>
    defHttp.delete({url: `${Api.AccountDelete}/${uid}`});

export const getUserInfoById=(uid:string)=>
    defHttp.get({url:`${Api.AccountInfo}/${uid}`})

